home *** CD-ROM | disk | FTP | other *** search
/ All for Cell Phones: Sony Ericsson / Sony-Ericsson 2004.iso / Java / ActView / ActiveViewer.jar / com / simeda / ActiveViewer / ConnectForm.class (.txt) next >
Encoding:
Java Class File  |  2001-12-12  |  3.7 KB  |  113 lines

  1. package com.simeda.ActiveViewer;
  2.  
  3. import javax.microedition.lcdui.Command;
  4. import javax.microedition.lcdui.Display;
  5. import javax.microedition.lcdui.Displayable;
  6. import javax.microedition.lcdui.Form;
  7. import javax.microedition.lcdui.TextField;
  8. import javax.microedition.rms.RecordStore;
  9. import javax.microedition.rms.RecordStoreException;
  10.  
  11. public class ConnectForm extends Form {
  12.    TextField hostname = new TextField("", "", 1, 1);
  13.    TextField display = new TextField("", "", 1, 1);
  14.    TextField password = new TextField("", "", 1, 1);
  15.    Command connectCommand = new Command("Connect", 4, 1);
  16.    // $FF: renamed from: rs javax.microedition.rms.RecordStore
  17.    RecordStore field_0 = null;
  18.    String currentDisplay = "";
  19.    String currentHostname = "";
  20.    String currentPassword = "";
  21.    VNCViewer parent = null;
  22.  
  23.    public ConnectForm(VNCViewer var1) {
  24.       super("Connection Information");
  25.       this.parent = var1;
  26.       ((Displayable)this).setCommandListener(new 1(this));
  27.  
  28.       try {
  29.          this.jbInit();
  30.       } catch (Exception var3) {
  31.          ((Throwable)var3).printStackTrace();
  32.       }
  33.  
  34.    }
  35.  
  36.    private void jbInit() {
  37.       try {
  38.          this.field_0 = RecordStore.openRecordStore("connectionInformation", true);
  39.          int var1 = this.field_0.getNumRecords();
  40.          if (var1 == 3) {
  41.             byte[] var2 = this.field_0.getRecord(1);
  42.             if (var2 != null) {
  43.                this.currentDisplay = new String(var2);
  44.             }
  45.  
  46.             var2 = this.field_0.getRecord(2);
  47.             if (var2 != null) {
  48.                this.currentHostname = new String(var2);
  49.             }
  50.  
  51.             var2 = this.field_0.getRecord(3);
  52.             if (var2 != null) {
  53.                this.currentPassword = new String(var2);
  54.             }
  55.          }
  56.       } catch (RecordStoreException var3) {
  57.          ((Throwable)var3).printStackTrace();
  58.       }
  59.  
  60.       this.display.setLabel("Display");
  61.       this.display.setConstraints(2);
  62.       this.display.setMaxSize(5);
  63.       this.display.setString(this.currentDisplay);
  64.       this.hostname.setLabel("Hostname");
  65.       this.hostname.setConstraints(0);
  66.       this.hostname.setMaxSize(30);
  67.       this.hostname.setString(this.currentHostname);
  68.       this.password.setLabel("Password");
  69.       this.password.setConstraints(65536);
  70.       this.password.setMaxSize(30);
  71.       this.password.setString(this.currentPassword);
  72.       ((Form)this).append(this.hostname);
  73.       ((Form)this).append(this.display);
  74.       ((Form)this).append(this.password);
  75.       ((Displayable)this).addCommand(this.connectCommand);
  76.    }
  77.  
  78.    public void this_commandPerformed(Command var1, Displayable var2) {
  79.       if (var1.getLabel().equals("Connect")) {
  80.          this.currentDisplay = this.display.getString();
  81.          this.currentHostname = this.hostname.getString();
  82.          this.currentPassword = this.password.getString();
  83.          byte[] var3 = this.currentDisplay.getBytes();
  84.          byte[] var4 = this.currentHostname.getBytes();
  85.          byte[] var5 = this.currentPassword.getBytes();
  86.          System.out.println("currentDisplay=" + this.currentDisplay);
  87.  
  88.          try {
  89.             if (this.field_0.getNumRecords() == 0) {
  90.                this.field_0.addRecord((byte[])null, 0, 0);
  91.                this.field_0.addRecord((byte[])null, 0, 0);
  92.                this.field_0.addRecord((byte[])null, 0, 0);
  93.             }
  94.  
  95.             this.field_0.setRecord(1, var3, 0, var3.length);
  96.             this.field_0.setRecord(2, var4, 0, var4.length);
  97.             this.field_0.setRecord(3, var5, 0, var5.length);
  98.             this.field_0.closeRecordStore();
  99.          } catch (Exception var7) {
  100.             ((Throwable)var7).printStackTrace();
  101.          }
  102.  
  103.          VNCController var6 = new VNCController(this);
  104.          var6.setHost(this.currentHostname);
  105.          var6.setPort(5900 + Integer.parseInt(this.currentDisplay));
  106.          var6.setPassword(this.currentPassword);
  107.          var6.setDisplay(Display.getDisplay(this.parent));
  108.          var6.doConnect();
  109.       }
  110.  
  111.    }
  112. }
  113.